package controllers;

import play.mvc.Before;
import ret.Ret;
import utils.NeedLogin;
import utils.SessionUtils;

public class LoginFilter extends SController {

    @Before
    public static void check() {
        if (null != request.invokedMethod.getAnnotation(NeedLogin.class)) {
            if(SessionUtils.getCurrentUser() == null) {
                renderJSON(Ret.redirect("/login"));
            }
        }
    }
}
